import org.junit.Test;

import java.util.Scanner;

import static junit.framework.TestCase.assertEquals;

public class NGuessNumberTest {
    public static void main(String[] args) {
        //getPlayerInputTest();
        System.out.println(NGuessNumber.isWin(NGuessNumber.compareGuessAnswer(new int[]{1,2,3,4},new int[]{1,2,3,4})));
    }

    @Test
    public void generateAnswerTest() {
        NGuessNumber nGuessNumber = new NGuessNumber();
        assertEquals(4, nGuessNumber.generateAnswer().length);
        System.out.println("数字数量为4，正确");
        int num[] = nGuessNumber.generateAnswer();
        boolean flag = true;
        int numsize = 0;
        for (int i = 0; i < 4; i++) {
            if (num[i] >= 0 && num[i] <= 9) {
                numsize ++;
            } else {
                numsize --;
            }
            for (int l = 0; l <= i; l++) {
                if (i != l) {
                    if (num[i] == num[l]) {
                        flag = false;
                    } else {
                        flag = true;
                    }
                }
            }
            if(flag == false){
                break;
            }
        }
        assertEquals(true, flag);
        System.out.println("其中无重复数字，正确");
        assertEquals(4, numsize);
        System.out.println("数字都在0-9之间，正确");
    }

    @Test
    public void getPlayerInputTest() {
        NGuessNumber nGuessNumber = new NGuessNumber();
        assertEquals(4,nGuessNumber.getPlayerInput().length);
        System.out.println("用户输入的数字数量为4，正确");
    }

    //测试compareGuessAnswer
    @Test
    public void compareGuessAnswerTest(){
        int[] guess = {1,2,4,5};
        int[] answer = {1,2,3,4};
        NGuessNumber.compareGuessAnswer(guess,answer);
    }
}
